package com.example.interviewrecorder.utils

import android.content.res.Configuration
import android.content.res.Resources
import android.util.TypedValue
import com.example.interviewrecorder.LyyApplicaiton

object ScreenUtil {
    fun convertDpToPx(dp: Float): Int {
        return TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP,
            dp,
            Resources.getSystem().displayMetrics
        ).toInt()
    }

    fun convertPxToDp(px: Float): Float {
        val density = Resources.getSystem().displayMetrics.density
        return px / density
    }

    //判断当前主题是否为深色模式
    fun isDarkTheme(): Boolean{
        val flag = LyyApplicaiton.context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
        return flag == Configuration.UI_MODE_NIGHT_YES
    }
}